<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = []
      let sum =0
      for(let i =0;arr.length<5;i++){
        let age = +prompt('请输入年龄(0-100之间)')
        if (age>=0&&age<=100){
          arr.push(age)
          sum +=age
        } 
        if (age>=18 && age <=100){
          document.write(`所有成年人的年龄为${age}<br>`)
        }
      }
      arr.sort(function(a,b){
        return a-b
      })
      document.write(`最小年龄为${arr[0]}<br>`)
      document.write(`最大年龄为${arr[arr.length - 1]}<br>`)
      document.write(`所有成年人的总年龄为：${sum}<br>`)
      document.write(`所有人的平均年龄为：${sum/arr.length}`)
    </script>
  </body>
</html>